.class public Lcom/nbsp/materialfilepicker/MaterialFilePicker;
.super Ljava/lang/Object;
.source "MaterialFilePicker.java"


# instance fields
.field private mActivity:Landroid/app/Activity;

.field private mChooseFolder:Z

.field private mCurrentPath:Ljava/lang/String;

.field private mDirectoriesFilter:Ljava/lang/Boolean;

.field private mFileFilter:Ljava/util/regex/Pattern;

.field private mRequestCode:Ljava/lang/Integer;

.field private mRootPath:Ljava/lang/String;

.field private mSaveTitle:Ljava/lang/String;

.field private mShowHidden:Ljava/lang/Boolean;


# direct methods
.method public constructor <init>()V
    .locals 2

    .line 30
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    const/4 v0, 0x0

    .line 22
    invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v1

    iput-object v1, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mDirectoriesFilter:Ljava/lang/Boolean;

    .line 25
    iput-object v1, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mShowHidden:Ljava/lang/Boolean;

    const/4 v1, 0x0

    .line 27
    iput-object v1, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mSaveTitle:Ljava/lang/String;

    .line 28
    iput-boolean v0, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mChooseFolder:Z

    return-void
.end method

.method private getFilter()Lcom/nbsp/materialfilepicker/filter/CompositeFilter;
    .locals 4

    .line 78
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    .line 80
    iget-object v1, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mShowHidden:Ljava/lang/Boolean;

    invoke-virtual {v1}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v1

    if-nez v1, :cond_0

    .line 81
    new-instance v1, Lcom/nbsp/materialfilepicker/filter/HiddenFilter;

    invoke-direct {v1}, Lcom/nbsp/materialfilepicker/filter/HiddenFilter;-><init>()V

    invoke-virtual {v0, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 84
    :cond_0
    iget-object v1, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mFileFilter:Ljava/util/regex/Pattern;

    if-eqz v1, :cond_1

    .line 85
    new-instance v2, Lcom/nbsp/materialfilepicker/filter/PatternFilter;

    iget-object v3, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mDirectoriesFilter:Ljava/lang/Boolean;

    invoke-virtual {v3}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v3

    invoke-direct {v2, v1, v3}, Lcom/nbsp/materialfilepicker/filter/PatternFilter;-><init>(Ljava/util/regex/Pattern;Z)V

    invoke-virtual {v0, v2}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 88
    :cond_1
    new-instance v1, Lcom/nbsp/materialfilepicker/filter/CompositeFilter;

    invoke-direct {v1, v0}, Lcom/nbsp/materialfilepicker/filter/CompositeFilter;-><init>(Ljava/util/ArrayList;)V

    return-object v1
.end method


# virtual methods
.method public setChooseFolder(Z)Lcom/nbsp/materialfilepicker/MaterialFilePicker;
    .locals 0

    .line 38
    iput-boolean p1, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mChooseFolder:Z

    return-object p0
.end method

.method public setSaveButtonText(Ljava/lang/String;)Lcom/nbsp/materialfilepicker/MaterialFilePicker;
    .locals 0

    .line 43
    iput-object p1, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mSaveTitle:Ljava/lang/String;

    return-object p0
.end method

.method public start()V
    .locals 4

    .line 92
    iget-object v0, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mActivity:Landroid/app/Activity;

    if-eqz v0, :cond_4

    .line 96
    iget-object v0, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mRequestCode:Ljava/lang/Integer;

    if-eqz v0, :cond_3

    .line 100
    invoke-direct {p0}, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->getFilter()Lcom/nbsp/materialfilepicker/filter/CompositeFilter;

    move-result-object v0

    .line 102
    new-instance v1, Landroid/content/Intent;

    iget-object v2, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mActivity:Landroid/app/Activity;

    const-class v3, Lcom/nbsp/materialfilepicker/ui/FilePickerActivity;

    invoke-direct {v1, v2, v3}, Landroid/content/Intent;-><init>(Landroid/content/Context;Ljava/lang/Class;)V

    const-string v2, "arg_filter"

    .line 103
    invoke-virtual {v1, v2, v0}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/io/Serializable;)Landroid/content/Intent;

    .line 105
    iget-object v0, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mRootPath:Ljava/lang/String;

    if-eqz v0, :cond_0

    const-string v2, "arg_start_path"

    .line 106
    invoke-virtual {v1, v2, v0}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    .line 109
    :cond_0
    iget-object v0, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mCurrentPath:Ljava/lang/String;

    if-eqz v0, :cond_1

    const-string v2, "arg_current_path"

    .line 110
    invoke-virtual {v1, v2, v0}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    .line 113
    :cond_1
    iget-object v0, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mSaveTitle:Ljava/lang/String;

    if-eqz v0, :cond_2

    const-string v2, "arg_choose_btn_text"

    .line 114
    invoke-virtual {v1, v2, v0}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    .line 117
    :cond_2
    iget-boolean v0, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mChooseFolder:Z

    const-string v2, "arg_choose_folder"

    invoke-virtual {v1, v2, v0}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Z)Landroid/content/Intent;

    .line 119
    iget-object v0, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mActivity:Landroid/app/Activity;

    iget-object v2, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mRequestCode:Ljava/lang/Integer;

    invoke-virtual {v2}, Ljava/lang/Integer;->intValue()I

    move-result v2

    invoke-virtual {v0, v1, v2}, Landroid/app/Activity;->startActivityForResult(Landroid/content/Intent;I)V

    return-void

    .line 97
    :cond_3
    new-instance v0, Ljava/lang/RuntimeException;

    const-string v1, "You must pass request code by calling withRequestCode method"

    invoke-direct {v0, v1}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 93
    :cond_4
    new-instance v0, Ljava/lang/RuntimeException;

    const-string v1, "You must pass activity by calling withActivity method"

    invoke-direct {v0, v1}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V

    throw v0
.end method

.method public withActivity(Landroid/app/Activity;)Lcom/nbsp/materialfilepicker/MaterialFilePicker;
    .locals 0

    .line 33
    iput-object p1, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mActivity:Landroid/app/Activity;

    return-object p0
.end method

.method public withFilter(Ljava/util/regex/Pattern;)Lcom/nbsp/materialfilepicker/MaterialFilePicker;
    .locals 0

    .line 53
    iput-object p1, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mFileFilter:Ljava/util/regex/Pattern;

    return-object p0
.end method

.method public withFilterDirectories(Z)Lcom/nbsp/materialfilepicker/MaterialFilePicker;
    .locals 0

    .line 58
    invoke-static {p1}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object p1

    iput-object p1, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mDirectoriesFilter:Ljava/lang/Boolean;

    return-object p0
.end method

.method public withHiddenFiles(Z)Lcom/nbsp/materialfilepicker/MaterialFilePicker;
    .locals 0

    .line 73
    invoke-static {p1}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object p1

    iput-object p1, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mShowHidden:Ljava/lang/Boolean;

    return-object p0
.end method

.method public withRequestCode(I)Lcom/nbsp/materialfilepicker/MaterialFilePicker;
    .locals 0

    .line 48
    invoke-static {p1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object p1

    iput-object p1, p0, Lcom/nbsp/materialfilepicker/MaterialFilePicker;->mRequestCode:Ljava/lang/Integer;

    return-object p0
.end method
